﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Windows.Forms;

namespace iSystem
{
	public class iDirectory
	{
		public static void CreateFolder( String createFolderPath )
		{
			if( !System.IO.Directory.Exists( createFolderPath ) )
				System.IO.Directory.CreateDirectory( createFolderPath );
		}
        /// <summary>
        /// Copy all files in one directory into another
        /// </summary>
        /// <param name="sSourceDir">Source directory</param>
        /// <param name="sDestDir">Destination directory</param>
        public static void CopyDirectoryFile(string sSourceDir, string sDestDir, bool isQuestion)
        {
            if (!Directory.Exists(sDestDir))
                Directory.CreateDirectory(sDestDir);

            foreach (string sSourceFile in Directory.GetFiles(sSourceDir))
            {
                string sDestFile = Path.Combine(sDestDir, Path.GetFileName(sSourceFile));
                //				File.Copy( sSourceFile, sDestFile, true );
                if (isQuestion && File.Exists(sDestFile))
                {
                    DialogResult res;
                    res = MessageBox.Show(sDestFile + "\n\nalready exists. Overwrite?",
                                           "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (res == DialogResult.No)
                        continue;	// Skip copying the file
                }

                File.Copy(sSourceFile, sDestFile, true);
            }
        }
	}
}
